//
//  CategoryNavagationBar.m
//  Youhuiju
//
//  Created by yutenys on 16/7/29.
//  Copyright © 2016年 yutenys. All rights reserved.
//

#import "CategoryTopView.h"
#import "YOSearchBar.h"
@interface CategoryTopView ()

@property(nonatomic,strong)YOSearchBar *mySearchBar;//搜索
@property(nonatomic,strong)UIButton *searchBarBttton;
@property(nonatomic,strong)UIButton *backButton;//返回
@property(nonatomic,strong)UIButton *emailButton;//消息
@property(nonatomic,strong)UIView *lineView;
@end

@implementation CategoryTopView

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self creatView];
    }
    return self;
}
-(void)creatView
{
    self.mySearchBar = [[ YOSearchBar alloc]init];
  _mySearchBar.backgroundColor = [UIColor colorWithHexString:@"e5e5e5"];
    [self addSubview:self.mySearchBar];
    [self.mySearchBar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.centerY.equalTo(self.mas_centerY);
        make.size.mas_offset(CGSizeMake(272 * FitW, 30 * FitH));
    }];
    
    self.searchBarBttton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.searchBarBttton.tag = 2;
    [self.searchBarBttton addTarget:self action:@selector(backButtonClickedAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.mySearchBar addSubview:self.searchBarBttton];
    [self.searchBarBttton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_offset(UIEdgeInsetsMake(0, 0, 0, 0));
    }];
    
    self.backButton = [UIButton buttonWithType:UIButtonTypeSystem];
     self.backButton.tag = 0;
    [self.backButton setBackgroundImage:LoadImage(@"back") forState:UIControlStateNormal];
    [self.backButton addTarget:self action:@selector(backButtonClickedAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.backButton];
    [self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(12 * FitW);
        make.top.equalTo(self.mas_top).offset(13 * FitH);
        make.size.mas_offset(CGSizeMake(19 * FitW, 19 * FitH));
    }];
    
    self.emailButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.emailButton.tag = 1;
    [self.emailButton setBackgroundImage:LoadImage(@"email") forState:UIControlStateNormal];
    [self.emailButton addTarget:self action:@selector(backButtonClickedAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.emailButton];
    [self.emailButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-12 * FitW);
        make.centerY.equalTo(self.mySearchBar.mas_centerY);
        make.size.mas_offset(CGSizeMake(19 * FitW, 19 * FitH));
    }];
    
    self.lineView = [[UIView alloc]init];
    self.lineView.backgroundColor = [UIColor colorWithHexString:@"eeeeee"];
    [self addSubview:self.lineView];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
        make.bottom.equalTo(self.mas_bottom);
        make.height.mas_offset(1 * FitH);
    }];
}

-(void)backButtonClickedAction:(UIButton *)sender
{
    if (self.backButtonClickedHandler)
    {
        self.backButtonClickedHandler(sender.tag);
    }
}

@end


